import React, { useState } from 'react'
import Child from "../child"
import { Button, message } from 'antd';
export default function Parent() {

  const [count, setCount] = useState(0);




  // const handleCrement = () => {
  //   setCount(count + 1);
  // };

  const handleCrement = () => {
    setTimeout(() => {
      setCount(count => count + 1); // 直接使用最新值
    }, 1000);
    console.log(count);
  };

  // const handleCrement = () => {
  //   setTimeout(() => {
  //     setCount(count => count + 1); // 直接使用最新值
  //   }, 1000);
  // };

  return (
    <div>
      <Button onClick={() => setCount(c => c + 1)}>当前值：{count}</Button>
      <Child onIncrement={handleCrement} />
    </div>
  )
}
